//
//  HWPromoteGameCell.m
//  HWPromoteProjectAPP
//
//  Created by 陈道斌 on 2020/2/26.
//  Copyright © 2020 陈道斌. All rights reserved.
//

#import "HWPromoteGameCell.h"

@interface HWPromoteGameCell()
@property (weak, nonatomic) IBOutlet UIView *beijingView;
@property (weak, nonatomic) IBOutlet UIImageView *icoIamgeView;


@property (weak, nonatomic) IBOutlet UILabel *gameNameLabel;

@property (weak, nonatomic) IBOutlet UILabel *fenchengbiliLabel;

@property(strong,nonatomic) NSArray *dataArr;
@property(strong,nonatomic) NSArray *icoArr;



@end


@implementation HWPromoteGameCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.beijingView.layer.cornerRadius = 12;
    self.beijingView.layer.masksToBounds = YES;
    self.icoIamgeView.layer.cornerRadius = 12;
    self.icoIamgeView.layer.masksToBounds = YES;
    
    CGFloat hengjianjuLiin = (kScreenW -  55*4)/5;
                
    self.dataArr = @[@"微信",@"QQ",@"朋友圈",@"复制分享"];
    self.icoArr = @[@"weixing_ico",@"QQtupian_ico",@"pengyouquna_ico",@"fuzhifenxiang_ico"];
    
    for (int i = 0 ; i < self.dataArr.count; i++) {
                    
             int row = i/4;
             int line = i%4;
//             int shulian = (line*2+2) -1;

             UIView *redview = [[UIView alloc]initWithFrame:CGRectMake(hengjianjuLiin+hengjianjuLiin*line+line*55, row*20+row*47+84+25, 55,47 )];
                      
                      
             redview.tag = i;
           //  redview.backgroundColor = [UIColor whiteColor];
           //  redview.backgroundColor = [UIColor redColor];
             [ self.contentView  addSubview:redview];
                        
          
             UITapGestureRecognizer *tap1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imviewTaKaifu:)];
             [redview addGestureRecognizer:tap1];
                        
                        
             UIImageView *imview = [[UIImageView alloc]initWithFrame:CGRectMake(15, 0,  24, 24)];
            imview.image = [UIImage imageNamed:self.icoArr[i]];
            // imview.backgroundColor = [UIColor yellowColor];
             imview.userInteractionEnabled = YES;
             imview.tag = i;
             [redview addSubview:imview];
                    
                    
                        
                       // UILabel
                UILabel *nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 30, 55, 17)];
                nameLabel.textAlignment = NSTextAlignmentCenter;
                nameLabel.font = [UIFont systemFontOfSize:12];
                nameLabel.textColor = RGB(68, 68, 68);
                [redview addSubview:nameLabel];
                        
                 nameLabel.text =  [NSString stringWithFormat:@"%@",self.dataArr[i]];
                     //   [self.labelMuArr addObject:nameLabel];
                        
                    
            }
             
    
    
    
    
    
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


-(void)setModel:(HWPromoteGameModel *)model {
    
    _model  = model;
    
    [self.icoIamgeView sd_setImageWithURL:[NSURL URLWithString:model.icon] placeholderImage:nil];
    self.gameNameLabel.text = [NSString stringWithFormat:@"%@",model.name];
    
    self.fenchengbiliLabel.text = [NSString stringWithFormat:@"分成比例: %@",model.fcbl];
    
    
    
}


- (void)imviewTaKaifu:(UITapGestureRecognizer *)sender {
    
    
    UIView *view = sender.view;
  //  NSInteger tag
    NSInteger tag = view.tag;
    
    
    [self.delegate HWPromoteGameCellxunzhong:tag PromoteGameModel:self.model];
    
    
    
    
    
    
    
    
    
    
}

@end
